package com.example.mail.utils;

import org.springframework.stereotype.Component;

import java.util.Random;

@Component
public class RandomUtil {

    public String verificationCode() {
        // 创建Random对象
        Random random = new Random();

        // 生成一个6位的随机数字验证码
        StringBuilder verificationCode = new StringBuilder();
        for (int i = 0; i < 6; i++) {
            int digit = random.nextInt(10); // 生成0到9之间的随机整数
            verificationCode.append(digit);
        }

        // 输出生成的验证码
        System.out.println("Generated Verification Code: " + verificationCode);
        return verificationCode.toString();
    }
}
